%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/connections.variables-orderBy"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 8, 11, 12, 39, 13, 15<br />2: PgSelect[10], PgSelect[17]<br />ᐳ: Access[28]<br />3: Connection[14], PgSelectRows[19]<br />ᐳ: 18, 20, 21<br />4: ConnectionItems[22]<br />ᐳ: 27, 29, 30, 31"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 14, 28, 22, 21, 29, 31<br /><br />ROOT Connectionᐸ10ᐳ[14]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 28<br /><br />ROOT __Item{3}ᐸ22ᐳ[25]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 25, 26, 35<br /><br />ROOT Edge{3}[26]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 36<br /><br />ROOT PgSelectSingle{4}ᐸpostᐳ[36]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5

    %% plan dependencies
    PgSelect10[["PgSelect[10∈0] ➊<br />ᐸpost+1ᐳ<br />More deps:<br />- Constantᐸ3ᐳ[39]"]]:::plan
    Object13{{"Object[13∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    ApplyInput15{{"ApplyInput[15∈0] ➊"}}:::plan
    Object13 & ApplyInput15 --> PgSelect10
    PgSelect17[["PgSelect[17∈0] ➊<br />ᐸpost(aggregate)ᐳ<br />More deps:<br />- Constantᐸ3ᐳ[39]"]]:::plan
    Object13 & ApplyInput15 --> PgSelect17
    Access11{{"Access[11∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access12{{"Access[12∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access11 & Access12 --> Object13
    Connection14[["Connection[14∈0] ➊<br />ᐸ10ᐳ<br />Dependents: 4<br />More deps:<br />- Constantᐸ3ᐳ[39]"]]:::plan
    PgSelect10 --> Connection14
    Access8{{"Access[8∈0] ➊<br />ᐸ0.orderByᐳ"}}:::plan
    __Value0["__Value[0∈0] ➊<br />ᐸvariableValuesᐳ"]:::plan
    __Value0 --> Access8
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access11
    __Value2 --> Access12
    Access8 --> ApplyInput15
    First18{{"First[18∈0] ➊"}}:::plan
    PgSelectRows19[["PgSelectRows[19∈0] ➊"]]:::plan
    PgSelectRows19 --> First18
    PgSelect17 --> PgSelectRows19
    PgSelectSingle20{{"PgSelectSingle[20∈0] ➊<br />ᐸpostᐳ"}}:::plan
    First18 --> PgSelectSingle20
    ConnectionItems22[["ConnectionItems[22∈0] ➊<br />Dependents: 3<br />More deps:<br />- Connection[14]"]]:::plan
    First27{{"First[27∈0] ➊<br />More deps:<br />- ConnectionItems[22]"}}:::plan
    Access28{{"Access[28∈0] ➊<br />ᐸ10.cursorDetailsᐳ<br />Dependents: 3"}}:::plan
    PgSelect10 --> Access28
    Last30{{"Last[30∈0] ➊<br />More deps:<br />- ConnectionItems[22]"}}:::plan
    PageInfo16{{"PageInfo[16∈1] ➊<br />More deps:<br />- Connection[14]"}}:::plan
    Access32{{"Access[32∈1] ➊<br />ᐸ14.hasNextPageᐳ<br />More deps:<br />- Connection[14]"}}:::plan
    Access33{{"Access[33∈1] ➊<br />ᐸ14.hasPreviousPageᐳ<br />More deps:<br />- Connection[14]"}}:::plan
    Edge26{{"Edge[26∈3]"}}:::plan
    __Item25[/"__Item[25∈3]<br />ᐸ22ᐳ<br />More deps:<br />- ConnectionItems[22]"\]:::itemplan
    PgCursor35{{"PgCursor[35∈3]<br />More deps:<br />- Access[28]"}}:::plan
    __Item25 & PgCursor35 --> Edge26
    __Item25 --> PgCursor35
    PgSelectSingle36{{"PgSelectSingle[36∈4]<br />ᐸpostᐳ"}}:::plan
    __Item25 --> PgSelectSingle36
    PgClassExpression37{{"PgClassExpression[37∈5]<br />ᐸ__post__.”headline”ᐳ"}}:::plan
    PgSelectSingle36 --> PgClassExpression37
    PgClassExpression38{{"PgClassExpression[38∈5]<br />ᐸ__post__.”author_id”ᐳ"}}:::plan
    PgClassExpression37 o--o PgClassExpression38

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value0,__Value2,Access8,PgSelect10,Access11,Access12,Object13,Connection14,ApplyInput15,PgSelect17,First18,PgSelectRows19,PgSelectSingle20,ConnectionItems22,First27,Access28,Last30 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PageInfo16,Access32,Access33 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item25,Edge26,PgCursor35 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelectSingle36 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression37,PgClassExpression38 bucket5

